package com.highspeed.bdk.controller.logic;

import com.bianmaba.spring.data.jpa.domain.Result;
import com.bianmaba.spring.mvc.method.support.annotations.JSON;
import com.highspeed.bdk.bean.entity.logic.App;
import com.highspeed.bdk.controller.base.BdkCrudController;
import com.highspeed.bdk.service.logic.IAppService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping(value = {"app"}, method = RequestMethod.POST)
@Api(tags = "应用")
public class AppController extends BdkCrudController<App, Integer> {

    @Autowired()
    private IAppService appService;

    @Override
    protected IAppService getService() {
        return this.appService;
    }

    @ApiOperation(value = "保存应用", notes = "参数为JSON数据;<br/>" +
            "每一个链路配置中中必须包含：logicTopology.id，不然不会与相关logicTopology关联（已经关联的则会断掉）;<br/>如果app里的有lins则会一起保存<br/>")
    @JSON
    @RequestMapping(value = "/save", method = RequestMethod.POST)
    @Override
    public Result save(@RequestBody @ApiParam(name = "entity") App entity) {
        return super.save(entity);
    }

    @ApiOperation(value = "保存逻辑链路列表", notes = "参数为JSON数据;<br/>" +
            "每一个链路配置中中必须包含：logicTopology.id，不然不会与相关logicTopology关联（已经关联的则会断掉）;<br/>如果app里的有lins则会一起保存<br/>")
    @JSON
    @RequestMapping(value = "/saves", method = RequestMethod.POST)
    @Override
    public Result save(@RequestBody @ApiParam(name = "entity") List<App> entity) {
        return super.save(entity);
    }
}
